﻿using System;
using System.Data;
using System.Data.SqlClient;
using Project.IDAO;
using Project.DTO;
using Project.DBMAPPING;

namespace Project.DAO
{
    /// <summary>
    /// Class define method(s) for logging in the system
    /// </summary>
    public class LoginDAO : ILoginDAO
    {
        /// <summary>
        /// Check for a valid user
        /// </summary>
        /// <param name="userInfo">User object</param>
        /// <returns>0: Incorrect info. 1:Valid user. 2:Inactive account</returns>
        public int IsValidUser(User userInfo)
        {
            // Declare variable to access database
            DbMappingDataContext database = new DbMappingDataContext();
            // Return value to indicate if a user is valid
            return database.SP_USER_CHECKLOGIN(userInfo.Username, userInfo.Password);
        }
    }
}
